/**
 * model 层的基类
 */
export class BaseModel extends Laya.EventDispatcher{
}

/**
 * 单类装饰器
 * @param target 
 * @param key 
 */
export function singleton(target: any, key: string) {
    let _val;
    let getter = function () {
        if(!_val) {
            _val = new target();
        }
        return _val;
    };
    Object.defineProperty(target, key, {get: getter});
}

/**
 * 属性事件装饰器
 * @param target 
 * @param key 
 */
export function eventProperty(target: any, key: string) {
    let _val;
    let getter = function () {
        return _val;
    };
    let setter = function (newVal) {
        _val = newVal;
        this.event(key)
    };
    Object.defineProperty(target, key, {
        get: getter,
        set: setter,
        enumerable: true,
        configurable: true
    });
}


    